<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('收益统计列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                           <!-- <li class="select-time">
                                <label style="width: 80px;">交易日期： </label>
                                <input type="text" class="time-input" readonly id="startTime" placeholder="开始时间" name="start"/>
                                <span>-</span>
                                <input type="text" class="time-input" readonly id="endTime" placeholder="结束时间" name="end"/>
                            </li>-->
                            <li class="select-time">
                                <label style="width: 80px;">交易日期： </label>
                                <input type="text" class="time-input" readonly id="startTime" placeholder="开始时间" name="starts"/>
                            </li>
                            <li>
                                <label style="width: 80px;">处理状态：</label>
                                <select name="status">
                                    <option value="">所有</option>
                                    <option value="0">正在处理</option>
                                    <option value="1">处理成功</option>
                                    <option value="2">处理失败</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 10px;"></label>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                <a class="btn btn-primary btn-rounded btn-sm" id="timer" data-type="0" onclick="openRefresh()"><i class="fa fa-refresh"></i>&nbsp;<span id="ss">开启实时刷新</span></a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add('450')" shiro:hasPermission="incomeInfo:incomeInfo:add">
                    <i class="fa fa-plus"></i> 新增报表
                </a>
                <a class="btn btn-warning" onclick="exportBb()" shiro:hasPermission="incomeInfo:incomeInfo:export">
                    <i class="fa fa-download"></i> 导出报表
                </a>
              <!--  <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="incomeInfo:incomeInfo:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="incomeInfo:incomeInfo:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="incomeInfo:incomeInfo:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('incomeInfo:incomeInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('incomeInfo:incomeInfo:remove')}]];
        var prefix = ctx + "incomeInfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "收益统计",
                firstLoad:true,
                clickToSelect:true,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'manuName',
                    title: '品牌名称'
                },
                {
                    field: 'status',
                    title: '处理状态',
                    formatter:function(value,row,index){
                        if (value == '0'){
                            return "<span style='color: blue'>正在处理</span>";
                        } else if (value == '1'){
                            return "<span style='color: green'>处理成功</span>";
                        } else if (value == '2'){
                            return "<span style='color: red'>处理失败</span>";
                        } else {
                            return "";
                        }
                    }
                },
                {
                    field: 'jjkAmount',
                    title: '借记卡交易总额',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'jjkProfit',
                    title: '借记卡分润总额',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'djkAmount',
                    title: '贷记卡交易总额',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'djkProfit',
                    title: '贷记卡分润总额',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'smAmount',
                    title: '扫码交易总额',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'smProfit',
                    title: '扫码分润总额',
                    formatter:function(value,row,index){
                       return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'llfAmount',
                    title: '流量费收益',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'fwfAmount',
                    title: '服务费收益',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                /*{
                    field: 'outProfit',
                    title: '应付分润'
                },
                {
                    field: 'notAward',
                    title: '应付奖励'
                },*/
                {
                    field: 'ycProfit',
                    title: '已出分润',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                {
                    field: 'ycAward',
                    title: '已出奖励',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },
                /*{
                    field: 'sjAmount',
                    title: '实付支出',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },*/
               /* {
                    field: 'cdAmount',
                    title: '沉淀金额',
                    formatter:function(value,row,index){
                        return $.table.rmbFormatter(value);
                    }
                },*/
                {
                    field: 'tradeDate',
                    title: '交易日期'
                },
                {
                    field: 'createDate',
                    title: '生成日期'
                },
                ]
            };
            $.table.init(options);
        });

        let timerId;
        function openRefresh() {
            var type = $("#timer").attr("data-type");
            if (type == 0){
                timerId = setInterval(function() {
                    $.table.search()
                }, 3000);
                $("#ss").text("关闭实时刷新")
                $("#timer").attr("data-type",'1')
            } else {
                $("#ss").text("开启实时刷新")
                clearTimeout(timerId);
                $("#timer").attr("data-type",'0')
            }
        }

        /**
         * 导出明细
         * @param
         */
        function exportBb(){
            $.modal.confirm("确定要导出收益明细报表吗?", function() {
                $.post(prefix + "/export",$("#formId").serialize(),function(result){
                    if (result.code == '0'){
                        $.modal.msgSuccess(result.msg);
                    } else {
                        $.modal.msgError(result.msg);
                    }
                    $.table.refresh();
                });
            })
        }

    </script>
</body>
</html>